using System;
using System.Data;
using System.Data.SqlClient;
using Entity;

namespace SalesVMT
{
    public class InventoryDB
    {

        
        public static DataSet GetList(out int ItemCount, string keyWord, int currentPage, int pageSize)
        {

            DataSet retVal = null;
            SqlConnection dbConn = SQLServerUtil.CreateConnection();
            SqlCommand dbCmd = new SqlCommand("SalesVMT_Inventory_GetList", dbConn);
            dbCmd.Parameters.AddWithValue("@KeyWord", keyWord);
            dbCmd.Parameters.AddWithValue("@CurrentPage", currentPage);
            dbCmd.Parameters.AddWithValue("@RPP", pageSize);
            dbCmd.CommandType = CommandType.StoredProcedure;
            try
            {
                retVal = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                da.Fill(retVal);
                ItemCount = Convert.ToInt32(retVal.Tables[1].Rows[0][0]);
            }
            finally
            {
                dbConn.Close();
            }
            return retVal;

        }
        public static DataSet GetQuantityByItem(int ItemID)
        {
            DataSet retVal = null;
            SqlConnection dbConn = SQLServerUtil.CreateConnection();

            SqlCommand dbCmd = new SqlCommand("SalesVMT_Inventory_GetQuantityByItem", dbConn);
            dbCmd.Parameters.AddWithValue("@ItemID", ItemID);
            dbCmd.CommandType = CommandType.StoredProcedure;
            try
            {
                retVal = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(dbCmd);
                da.Fill(retVal);
            }
            finally
            {
                dbConn.Close();
            }
            return retVal;
        }

    }
}
